package com.kobeliu.strategy;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class ShardingDBConfig {

    /**
     * 存储数据库位置编号
     */
    private static final List<String> dbPrefixList = new ArrayList<>();
    private static Random random = new Random();

    static {
        dbPrefixList.add("0");
        dbPrefixList.add("1");
        dbPrefixList.add("a");
    }

    /**
     * 随机获取一个库位
     * @return
     */
    public static String getRandomDBPrefix(){

        int index = random.nextInt(dbPrefixList.size()-1);
        return dbPrefixList.get(index);
    }
}
